/*
 * AddQueryPanel.java
 *
 * Created on Aug 12, 2013, 4:32:35 PM
 */
package ngram_reader.viewer;

import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JComboBox;
import javax.swing.JSpinner;
import main.NGramWorker;
import ngram.util.GuiUtil;
import math.mathExtended.MathExtended;
import ngram_reader.viewer.query.NGramSearchQuery;
import ngram_reader.viewer.query.StatisticsSearchQuery.Aggregate;
import ngram_reader.viewer.query.StatisticsSearchQuery.Range;
import ngram_reader.viewer.query.NoStatSearchQuery.Match;
import ngram_reader.viewer.query.SearchQueryFactory;
import swingExtended.todoQueue.TaskManager;
import swingExtended.SwingExtended;

/**
 *
 * @author g1wshimu
 */
public class AddQueryPanel extends javax.swing.JPanel {

    private TaskManager<NGramSearchQuery> taskManager;
    
    /** Creates new form AddQueryPanel */
    public AddQueryPanel() {
        initComponents();
        GuiUtil.addEnumAsOptions(Match.class, this.dropDownMatch);

        GuiUtil.addEnumAsOptions(Range.class, this.dropDownYear);
        GuiUtil.addEnumAsOptions(Range.class, this.dropDownMatchCount);
        GuiUtil.addEnumAsOptions(Range.class, this.dropDownVolumeCount);

        GuiUtil.addEnumAsOptions(Aggregate.class, this.dropDownMatchAggregate);
        GuiUtil.addEnumAsOptions(Aggregate.class, this.dropDownVolumeAggregate);
                
        // Get the preferences
        //final PreferenceGroup PREF_GROUP = new PreferenceGroup(Preferences.userRoot().node(
        //        Main.USER_PREF_ROOT_NODE + "/" + this.getClass()));
        
        //PREF_GROUP.add(checkBoxMatchCase, "matchCase");
        //PREF_GROUP.add(checkBoxIgnoreStatistics, "ignoreStatistics");
        //PREF_GROUP.add(spinnerNGramStart, "startNGram");
        //PREF_GROUP.add(spinnerNGramEnd, "endNGram");
        //PREF_GROUP.loadPreferences();
                
        // Properly disable the options
        this.checkBoxIgnoreStatisticsActionPerformed(null);
        this.dropDownYearActionPerformed(null);
        this.dropDownMatchCountActionPerformed(null);
        this.dropDownVolumeCountActionPerformed(null);        
    
        this.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentHidden(ComponentEvent e) {
                //PREF_GROUP.savePreferences();
            }
        });
    }
    
    public void setTaskManager(TaskManager<NGramSearchQuery> manager) {
        this.taskManager = manager;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelSearch = new javax.swing.JLabel();
        textFieldSearch = new javax.swing.JTextField();
        dropDownMatch = new javax.swing.JComboBox();
        checkBoxMatchCase = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        spinnerNGramStart = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        spinnerNGramEnd = new javax.swing.JSpinner();
        jLabel3 = new javax.swing.JLabel();
        checkBoxIgnoreStatistics = new javax.swing.JCheckBox();
        labelYear = new javax.swing.JLabel();
        dropDownYear = new javax.swing.JComboBox();
        spinnerYear1 = new javax.swing.JSpinner();
        spinnerYear2 = new javax.swing.JSpinner();
        labelMatchCount = new javax.swing.JLabel();
        dropDownMatchCount = new javax.swing.JComboBox();
        spinnerMatch1 = new javax.swing.JSpinner();
        spinnerMatch2 = new javax.swing.JSpinner();
        dropDownMatchAggregate = new javax.swing.JComboBox();
        labelVolumeCount = new javax.swing.JLabel();
        dropDownVolumeCount = new javax.swing.JComboBox();
        spinnerVolume1 = new javax.swing.JSpinner();
        spinnerVolume2 = new javax.swing.JSpinner();
        dropDownVolumeAggregate = new javax.swing.JComboBox();
        buttonAdd = new javax.swing.JButton();

        labelSearch.setText("Search word/phrase");

        textFieldSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldSearchActionPerformed(evt);
            }
        });

        checkBoxMatchCase.setText("Match Case");
        checkBoxMatchCase.setToolTipText("The n-gram must match the case exactly.");

        jLabel1.setText("Search");

        spinnerNGramStart.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
        spinnerNGramStart.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                spinnerNGramStartStateChanged(evt);
            }
        });

        jLabel2.setText("gram to");

        spinnerNGramEnd.setModel(new javax.swing.SpinnerNumberModel(1, 1, 5, 1));
        spinnerNGramEnd.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                spinnerNGramEndStateChanged(evt);
            }
        });

        jLabel3.setText("gram");

        checkBoxIgnoreStatistics.setSelected(true);
        checkBoxIgnoreStatistics.setText("Ignore Statistics");
        checkBoxIgnoreStatistics.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkBoxIgnoreStatisticsActionPerformed(evt);
            }
        });

        labelYear.setText("Year:");

        dropDownYear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dropDownYearActionPerformed(evt);
            }
        });

        labelMatchCount.setText("Match Count:");

        dropDownMatchCount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dropDownMatchCountActionPerformed(evt);
            }
        });

        labelVolumeCount.setText("Volume Count:");

        dropDownVolumeCount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dropDownVolumeCountActionPerformed(evt);
            }
        });

        buttonAdd.setText("Add");
        buttonAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAddActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(checkBoxIgnoreStatistics)
                    .addComponent(labelSearch)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(textFieldSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dropDownMatch, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(checkBoxMatchCase))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinnerNGramStart, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinnerNGramEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3))
                    .addComponent(labelMatchCount)
                    .addComponent(labelVolumeCount)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(dropDownMatchCount, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(spinnerMatch1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(dropDownVolumeCount, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(spinnerVolume1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(spinnerMatch2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinnerVolume2, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dropDownMatchAggregate, 0, 132, Short.MAX_VALUE)
                            .addComponent(buttonAdd, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(dropDownVolumeAggregate, javax.swing.GroupLayout.Alignment.TRAILING, 0, 132, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(dropDownYear, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinnerYear1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinnerYear2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(55, 55, 55))
                    .addComponent(labelYear))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerMatch1, spinnerMatch2, spinnerVolume1, spinnerVolume2, spinnerYear1, spinnerYear2});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelSearch)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dropDownMatch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkBoxMatchCase))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(spinnerNGramStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(spinnerNGramEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(checkBoxIgnoreStatistics)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelYear)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(dropDownMatchCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinnerMatch1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinnerMatch2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dropDownMatchAggregate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelVolumeCount))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(dropDownYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinnerYear1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinnerYear2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelMatchCount)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dropDownVolumeCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(spinnerVolume1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(spinnerVolume2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dropDownVolumeAggregate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonAdd)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerMatch1, spinnerMatch2, spinnerVolume1, spinnerVolume2, spinnerYear1, spinnerYear2});

    }// </editor-fold>//GEN-END:initComponents

private void buttonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAddActionPerformed
    NGramSearchQuery searchQuery;
    String query = textFieldSearch.getText(),
            startGram = spinnerNGramStart.getValue().toString(),
            endGram = spinnerNGramEnd.getValue().toString();
    try {
        searchQuery = SearchQueryFactory.getSearchQuery(query,
                (Match) dropDownMatch.getSelectedItem(),
                startGram, endGram, checkBoxMatchCase.isSelected(),
                getMin(dropDownYear, spinnerYear1, spinnerYear2),
                getMax(dropDownYear, spinnerYear1, spinnerYear2),
                getMin(dropDownMatchCount, spinnerMatch1, spinnerMatch2),
                getMax(dropDownMatchCount, spinnerMatch1, spinnerMatch2),
                getMin(dropDownVolumeCount, spinnerVolume1, spinnerVolume2),
                getMax(dropDownVolumeCount, spinnerVolume1, spinnerVolume2),
                (Aggregate) dropDownMatchAggregate.getSelectedItem(),
                (Aggregate) dropDownVolumeAggregate.getSelectedItem(), 
                checkBoxIgnoreStatistics.isSelected());
    } catch (IllegalArgumentException ex) {
        SwingExtended.openWarningWindow(this, "", ex);
        return;
    }
    taskManager.addItem(searchQuery);
}//GEN-LAST:event_buttonAddActionPerformed

private void dropDownVolumeCountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dropDownVolumeCountActionPerformed
    this.getMin(dropDownVolumeCount, spinnerVolume1, spinnerVolume2);
    // Enable dropDownVolumeAggregate only if the selected item is not "Any"
    this.dropDownVolumeAggregate.setEnabled(dropDownVolumeCount.getSelectedItem() != Range.ALL);
}//GEN-LAST:event_dropDownVolumeCountActionPerformed

private void dropDownMatchCountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dropDownMatchCountActionPerformed
    this.getMin(dropDownMatchCount, spinnerMatch1, spinnerMatch2);
    // Enable dropDownMatchAggregate only if the selected item is not "Any"
    this.dropDownMatchAggregate.setEnabled(dropDownMatchCount.getSelectedItem() != Range.ALL);
}//GEN-LAST:event_dropDownMatchCountActionPerformed

private void dropDownYearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dropDownYearActionPerformed
    this.getMin(dropDownYear, spinnerYear1, spinnerYear2);
}//GEN-LAST:event_dropDownYearActionPerformed

private void checkBoxIgnoreStatisticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxIgnoreStatisticsActionPerformed
    boolean enable = !this.checkBoxIgnoreStatistics.isSelected();
    GuiUtil.setEnabled(enable,
            labelYear, dropDownYear, spinnerYear1, spinnerYear2,
            labelMatchCount, dropDownMatchCount, dropDownMatchAggregate, spinnerMatch1, spinnerMatch2,
            labelVolumeCount, dropDownVolumeCount, dropDownVolumeAggregate, spinnerVolume1, spinnerVolume2);
    if (enable) {
        this.dropDownYearActionPerformed(evt);
        this.dropDownMatchCountActionPerformed(evt);
        this.dropDownVolumeCountActionPerformed(evt);
    }
}//GEN-LAST:event_checkBoxIgnoreStatisticsActionPerformed

private void textFieldSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldSearchActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_textFieldSearchActionPerformed

private void spinnerNGramStartStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerNGramStartStateChanged
    int start = MathExtended.parseInt(spinnerNGramStart.getValue().toString(), NGramWorker.MIN_GRAM);
    int end = MathExtended.parseInt(spinnerNGramEnd.getValue().toString(), NGramWorker.MAX_GRAM);
    if (end < start) {
        spinnerNGramEnd.setValue(start);
    }
}//GEN-LAST:event_spinnerNGramStartStateChanged

private void spinnerNGramEndStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerNGramEndStateChanged
    int start = MathExtended.parseInt(spinnerNGramStart.getValue().toString(), NGramWorker.MIN_GRAM);
    int end = MathExtended.parseInt(spinnerNGramEnd.getValue().toString(), NGramWorker.MAX_GRAM);
    if (start > end) {
        spinnerNGramStart.setValue(end);
    }
}//GEN-LAST:event_spinnerNGramEndStateChanged

    private int getMin(JComboBox dropDown, JSpinner spinner1, JSpinner spinner2) {
        switch ((Range) dropDown.getSelectedItem()) {

            case ALL:
                spinner1.setEnabled(false);
                spinner2.setEnabled(false);
                return Integer.MIN_VALUE;

            case BETWEEN:
                spinner1.setEnabled(true);
                spinner2.setEnabled(true);
                return MathExtended.parseInt(spinner1.getValue().toString(),
                        Integer.MIN_VALUE);

            case GREATER_THAN:
                spinner1.setEnabled(true);
                spinner2.setEnabled(false);
                return MathExtended.parseInt(spinner1.getValue().toString(),
                        Integer.MIN_VALUE);

            case LESS_THAN:
                spinner1.setEnabled(true);
                spinner2.setEnabled(false);
                return Integer.MIN_VALUE;

            default:
                return Integer.MIN_VALUE;
        }
    }

    private int getMax(JComboBox dropDown, JSpinner spinner1, JSpinner spinner2) {
        switch ((Range) dropDown.getSelectedItem()) {

            case ALL: // Any Year
                GuiUtil.setEnabled(false, spinner1, spinner2);
                return Integer.MAX_VALUE;

            case BETWEEN: // Between
                GuiUtil.setEnabled(true, spinner1, spinner2);
                return MathExtended.parseInt(spinner2.getValue().toString(),
                        Integer.MAX_VALUE);

            case GREATER_THAN: // Greater than
                spinner1.setEnabled(true);
                spinner2.setEnabled(false);
                return Integer.MAX_VALUE;

            case LESS_THAN: // Less than                
                spinner1.setEnabled(true);
                spinner2.setEnabled(false);
                return MathExtended.parseInt(spinner2.getValue().toString(),
                        Integer.MAX_VALUE);

            default:
                return Integer.MAX_VALUE;
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAdd;
    private javax.swing.JCheckBox checkBoxIgnoreStatistics;
    private javax.swing.JCheckBox checkBoxMatchCase;
    private javax.swing.JComboBox dropDownMatch;
    private javax.swing.JComboBox dropDownMatchAggregate;
    private javax.swing.JComboBox dropDownMatchCount;
    private javax.swing.JComboBox dropDownVolumeAggregate;
    private javax.swing.JComboBox dropDownVolumeCount;
    private javax.swing.JComboBox dropDownYear;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel labelMatchCount;
    private javax.swing.JLabel labelSearch;
    private javax.swing.JLabel labelVolumeCount;
    private javax.swing.JLabel labelYear;
    private javax.swing.JSpinner spinnerMatch1;
    private javax.swing.JSpinner spinnerMatch2;
    private javax.swing.JSpinner spinnerNGramEnd;
    private javax.swing.JSpinner spinnerNGramStart;
    private javax.swing.JSpinner spinnerVolume1;
    private javax.swing.JSpinner spinnerVolume2;
    private javax.swing.JSpinner spinnerYear1;
    private javax.swing.JSpinner spinnerYear2;
    private javax.swing.JTextField textFieldSearch;
    // End of variables declaration//GEN-END:variables
}
